<template>
	<view class="main-view">
		
		
		<view @click="enrollManage(enrollMeta.id)"  class="enroll-item dashboard" v-for="enrollMeta in enrollMetas" :key="enrollMeta.startTime">
			<view class="enroll-title">{{enrollMeta.title}}</view>
			
			<view class="enroll-time">{{formatDatetime.formatDatetime(new Date(enrollMeta.startTime))}}</view>
			
			<view class="enroll-status" v-bind:style="{color:(enrollMeta.status==0?'green':'red')}">{{enrollMetaStatusTran(enrollMeta.status)}}</view>
			<!-- <button class="enroll-button">查看</button> -->
		</view>
		
		<!-- <button @click="more">加载更多</button> -->
	</view>
</template>
	
	

<script>
	import formatDatetime from "../../common/zdateutil.js"
	import tranUtil from "../../common/znumtranutil.js"
	export default {
		
		data() {
			return {
				userId : "",
				enrollMetas : [],
				formatDatetime : null,
				enrollMetaStatusTran : null,
				eId : ""
			}
		},
		onLoad : function() {
			// console.log(formatDatetime.formatDatetime)
			this.formatDatetime = formatDatetime;
			this.enrollMetaStatusTran = tranUtil.tranUtil.enrollMetaStatusTran;
			// console.log(this.enrollMetaStatusTran)
			var token;

			var vm = this;
			// 载入用户id
			uni.getStorage({
				key : 'userToken',
				success :function(res){
					token = res.data;
					vm.userId = token.userId;
					var param = {'length':10,'lastTimeLong':new Date().getTime()}
					vm.$get(vm.enrollurl + '/enroll/moreEnrollMeta',param,function(res){
						var data = res.data;
						if(data.code != 0){
							// vm.errorText = data.message;
							return;
						}
						vm.enrollMetas = data.object;
					});
				},
				fail : function(){
					uni.navigateTo({
						url : 'index'
					})
				}
			});
			
		},
		methods: {
			newEnroll : function(){
				uni.navigateTo({
					url : '../enroll/newEnrollDesc'
				})
			},
			more : function(){
				var vm = this;
				var param = {'length':10,'lastTimeLong':this.enrollMetas[this.enrollMetas.length - 1].startTime}
				this.$get(this.enrollurl + '/enroll/moreEnrollMeta',param,function(res){
					var data = res.data;
					if(data.code != 0){
						// vm.errorText = data.message;
						return;
					}
					vm.enrollMetas = vm.enrollMetas.concat(data.object);
				});
			},
			enrollManage : function(id){
				uni.navigateTo({
					url : './enrollManagePage?id=' + id
				})
			}
		}
	}
</script>

<style>
	@import '../../common/zcss.css';
	.main-view{
		width: 100%;
		flex-direction: column;
	}
	.enroll-item{
		border: 1upx solid gray;
		height: 150upx;
		position: relative;
		width: 99%;
		margin-bottom: 3upx;
		/* background-color: white; */
		/* background-color: azure; */
	}
	/* .enroll-button{
		position: absolute;
		font-size:40upx;
		height:80upx;
		width: 160upx;
		right: 1%;
	} */
	.enroll-time{
		position: absolute;
		font-size: 20upx;
		color: gray;
		left: 1%;
		bottom: 0%;
	}
	.enroll-status{
		position: absolute;
		font-size: 20upx;
		right: 1%;
		bottom: 1%;
	}
	.enroll-title{
		font-size: 50upx;
		position: absolute;
		top: 1%;
		left: 1%;
	}
</style>
